//
//  LOLListTableViewcell.m
//  LOLXXbox
//
//  Created by dllo on 16/2/29.
//  Copyright © 2016年 Grasstrio. All rights reserved.
//

#import "LOLListTableViewcell.h"
#import <Masonry.h>
#import <UIImageView+WebCache.h>
@implementation LOLListTableViewcell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.urlImageViews = [[UIImageView alloc] init];
        [self.contentView addSubview:self.urlImageViews];
        
        self.titleLabel = [[UILabel alloc] init];
        self.titleLabel.numberOfLines = 0;
        [self.contentView addSubview:self.titleLabel];
        
        self.timelabel = [[UILabel alloc] init];
        self.timelabel.font = [UIFont systemFontOfSize:16];
        [self.contentView addSubview:self.timelabel];
        
        self.buttonView = [[UIImageView alloc] init];
        [self.contentView addSubview:self.buttonView];
        
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    [self.urlImageViews mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(5);
        make.left.equalTo(self.contentView).offset(5);
        make.bottom.equalTo(self.contentView).offset(-5);
        make.width.equalTo(@120);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.contentView).offset(5);
        make.left.equalTo(self.urlImageViews.mas_right).offset(5);
        make.right.equalTo(self.contentView).offset(-5);
        make.height.equalTo(@50);
    }];
    
    [self.timelabel mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.equalTo(self.contentView).offset(-5);
        make.left.equalTo(self.urlImageViews.mas_right).offset(5);
        make.width.equalTo(@80);
        make.height.equalTo(@30);
    }];
    
   
    [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
        

        make.width.equalTo(@30);
        make.height.equalTo(@30);
        make.bottom.equalTo(self.contentView).offset(-5);
        make.right.equalTo(self.contentView).offset(-15);
    }];

}


- (void)setMyNewModel:(LOLNewmodel *)myNewModel{
    _myNewModel = myNewModel;
    [self.urlImageViews sd_setImageWithURL:[NSURL URLWithString:self.myNewModel.cover_url]];
    self.titleLabel.text = self.myNewModel.title;
    
    NSRange r;
    r.location = 5;
    r.length = 6;
    NSString *string = _myNewModel.upload_time;
    NSString *strSub = [string substringWithRange:r];
    NSString *sdate = [NSString stringWithFormat:@"%@",strSub];
    self.timelabel.text = sdate;

    self.buttonView.image = [UIImage imageNamed:@"down"];
}

@end
